﻿using SRB.Tg.DrawingStandard;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Teigha.DatabaseServices;
using Teigha.Geometry;

namespace SRB.Tg.Model
{
    public  class DrawingSteelTower
    {
        #region  Y方案
        #region Y型
        public static void DrawingYGemstoneShapeElevation(Database db, Point2d stpointLM, ref Extents2d ext,double pierH, double topWidth, double topW, double slopeW, double slopeL, double brslope, System.Data.DataRow dr,double scale=200)
        {
            TextPloter.AddTitle(db, stpointLM.C2D(0, 22 * scale), ref ext, "立面", "", scale);
           
            SteelTowerStructure.DrawYGemstoneShapeElevation(db, stpointLM.C2D(), ref ext, topWidth, slopeL, brslope, dr, pierH, "H钢筋");
            DimPloter.AddArrowTitle(db, stpointLM.C3D(-ext.W()*0.4, 18 * scale), "降落", ref ext, 2.5, scale, true);
            DimPloter.AddArrowTitle(db, stpointLM.C3D(ext.W() * 0.4, 18 * scale), "起飞", ref ext, 2.5, scale);
        }

        public static void DrawingYGemstoneShapeLeftSide(Database db, Point2d stpointLM, ref Extents2d ext, double pierH, double topWidth, double topW, double slopeW, double slopeL, double brslope, System.Data.DataRow dr, double scale = 200)
        {
            Extents2d extSide = new Extents2d(stpointLM, stpointLM);
            TextPloter.AddTitle(db, stpointLM.C2D(0, 18 * scale), ref ext, "A-A", "", scale);
            SteelTowerStructure.DrawYGemstoneShapeSide(db, stpointLM.C2D(), ref extSide, topWidth, topW, slopeW, brslope, dr,true, "H钢筋");
            TextPloter.AddTitle(db, stpointLM.C2D(extSide.W() * 1.2, 18 * scale), ref ext, "B-B", "", scale);
            SteelTowerStructure.DrawYGemstoneShapeInnerSide(db, stpointLM.C2D(extSide.W() * 1.2), ref extSide, topWidth, topW, slopeW, brslope, dr, true, "H钢筋");
            ext= ext.Add(extSide);
        }

        public static void DrawingYGemstoneShapeRightSide(Database db, Point2d stpointLM, ref Extents2d ext, double pierH, double topWidth, double topW, double slopeW, double slopeL, double brslope, System.Data.DataRow dr, double scale = 200)
        {
            Extents2d extSide = new Extents2d(stpointLM, stpointLM);
            TextPloter.AddTitle(db, stpointLM.C2D(0, 18 * scale), ref ext, "C-C", "", scale);
            SteelTowerStructure.DrawYGemstoneShapeSide(db, stpointLM.C2D(), ref extSide, topWidth, topW, slopeW, brslope, dr, false, "H钢筋");
            TextPloter.AddTitle(db, stpointLM.C2D(extSide.W() * 1.2, 18 * scale), ref ext, "D-D", "", scale);
            SteelTowerStructure.DrawYGemstoneShapeInnerSide(db, stpointLM.C2D(extSide.W()*1.2), ref extSide, topWidth, topW, slopeW, brslope, dr, false, "H钢筋");
            string text = @"注
 1.本图尺寸均以毫米为单位。";;

            Point3d p = stpointLM.C3D(extSide.W() * 0.3 , - extSide.L() -5*scale);
            TextPloter.AddMText(db, p, ref extSide, text, scale, 2.5, 55 * scale, Extensions.curFont);
            ext = ext.Add(extSide);
        }
        #endregion

        #region 宝石型
        public static void DrawingGemstoneShapeElevation(Database db, Point2d stpointLM, ref Extents2d ext, double pierH, double topWidth, double topW, double slopeW, double slopeL, double brslope, System.Data.DataRow dr,out int index,int startIndex=0, double scale = 200)
        {
            double hh = 0;
            Extents2d extSide = new Extents2d(stpointLM, stpointLM);
            SteelTowerStructure.DrawGemstoneShape(db, stpointLM.C2D(), ref extSide, pierH,topWidth,  slopeL, brslope, dr,out hh,out index, startIndex, "H钢筋",scale,true);
            ext = new Extents2d(stpointLM.C2D(0, -hh + 8 * scale), stpointLM.C2D(0, -hh + 8 * scale));
            TextPloter.AddTitle(db, stpointLM.C2D(0,-hh+ 8 * scale), ref extSide, "立面", "", scale);
            ext = ext.Add(extSide);
        }

        public static void DrawingGemstoneShapeSide(Database db, Point2d stpointLM, ref Extents2d ext, double pierH, double topWidth, double topW, double slopeW, double slopeL, double brslope, System.Data.DataRow dr, out int index, int startIndex = 0, double scale = 200,string refPName="")
        {
            double hh = 0;
            Extents2d extSide = new Extents2d(stpointLM, stpointLM);
            SteelTowerStructure.DrawGemstoneShape(db, stpointLM.C2D(), ref extSide, pierH, topW, slopeW, brslope, dr, out hh, out index, startIndex, "H钢筋");
            double w = extSide.W();
            double hs = 0;
            SteelTowerStructure.DrawGemstoneSectionShape(db, stpointLM.C2D(extSide.W()-5*scale), ref extSide, pierH, topW, slopeW, topW, slopeW, brslope, dr,out hs, startIndex, "H钢筋",scale);

            TextPloter.AddTitle(db, stpointLM.C2D(0, -hh+8 * scale), ref extSide, "E-E", "", scale);
            string text = @"注
 1.本图尺寸均以毫米为单位。";
            string steel_tower_type = dr["steel_tower_type"].ToString();
            //if (steel_tower_type == "2")
            //    text += "\\P 2.从塔顶计算,高度" + hh / 1000 + "m内参考:" + refPName;
            if (steel_tower_type == "1"|| steel_tower_type == "2")
            {
                string pierNo = dr["name"].ToString();
                if (pierNo != "P1")
                {
                    text += "\\P 2.从塔顶计算,高度" + hh / 1000 + "m内参考:" + refPName;
                }
            }

            Point3d p = stpointLM.C3D(w * 0.6+10 * scale, -hh - hs-5*scale);
            TextPloter.AddMText(db, p, ref extSide, text, scale, 2.5, 55 * scale, Extensions.curFont);
            ext = ext.Add(extSide);
        }

        #endregion


        #endregion

        #region T方案
        #region 宝石型

        public static void DrawingGemstoneShapeElevation(Database db, Point2d stpointLM, ref Extents2d ext, double pierH, double topWidth, double topW, double slopeW, double slopeL, double brslope, System.Data.DataRow dr, double scale = 200)
        {
            double hh = 0;
            Extents2d extSide = new Extents2d(stpointLM, stpointLM);
            SteelTowerStructure.DrawGemstoneShape(db, stpointLM.C2D(), ref extSide, pierH, topWidth, slopeL, brslope, dr, "H钢筋", scale, true);
            ext = new Extents2d(stpointLM.C2D(0, -hh + 8 * scale), stpointLM.C2D(0, -hh + 8 * scale));
            TextPloter.AddTitle(db, stpointLM.C2D(0, -hh + 8 * scale), ref extSide, "立面", "", scale);
            ext = ext.Add(extSide);
        }
        public static void DrawingGemstoneShapeElevationRotate(Database db, Point2d stpointLM, ref Extents2d ext, double pierH, double topWidth, double topW, double slopeW, double slopeL, double brslope, System.Data.DataRow dr,  double scale = 200)
        {
            double hh = 0;
            Extents2d extSide = new Extents2d(stpointLM, stpointLM);
            SteelTowerStructure.DrawGemstoneShapeRotate(db, stpointLM.C2D(), ref extSide, pierH, topWidth, slopeL, brslope, dr, "H钢筋", scale, true);
            ext = new Extents2d(stpointLM.C2D(), stpointLM.C2D());
            TextPloter.AddTitleRotate(db, stpointLM.C2D(-8*scale,0), ref extSide, "立面", "", scale);
            ext = ext.Add(extSide);
        }

        public static void DrawingGemstoneShapeSide(Database db, Point2d stpointLM, ref Extents2d ext, double pierH, double topWidth, double topW, double slopeW, double slopeL, double brslope, System.Data.DataRow dr,  double scale = 200, string refPName = "")
        {
            Extents2d extSide = new Extents2d(stpointLM, stpointLM);
            SteelTowerStructure.DrawGemstoneShape(db, stpointLM.C2D(), ref extSide, pierH, topW, slopeW, brslope, dr,  "H钢筋", scale);
            double w = extSide.W();
            double hs = 0,ws=0;
            SteelTowerStructure.DrawGemstoneSectionShape(db, stpointLM.C2D(extSide.W()), ref extSide, pierH, topW, slopeW, topW, slopeL, brslope, dr,out hs, out ws, "H钢筋", scale);

            TextPloter.AddTitle(db, stpointLM.C2D(0, 8 * scale), ref extSide, "A-A", "", scale);
            string text = @"注
 1.本图尺寸均以毫米为单位。";
            string steel_tower_type = dr["steel_tower_type"].ToString();
          
            Point3d p = stpointLM.C3D(w-ws * 0.5,-hs - 10 * scale);
            TextPloter.AddMText(db, p, ref extSide, text, scale, 2.5, 55 * scale, Extensions.curFont);
            ext = ext.Add(extSide);
        }
        public static void DrawingGemstoneShapeSideRotate(Database db, Point2d stpointLM, ref Extents2d ext, double pierH, double topWidth, double topW, double slopeW, double slopeL, double brslope, System.Data.DataRow dr, double scale = 200, string refPName = "")
        {
            Extents2d extSide = new Extents2d(stpointLM, stpointLM);
            SteelTowerStructure.DrawGemstoneShapeRotate(db, stpointLM.C2D(), ref extSide, pierH, topW, slopeW, brslope, dr, "H钢筋", scale);
            double w = extSide.W();
            double h = extSide.L();
            double hs = 0, ws = 0;
            SteelTowerStructure.DrawGemstoneSectionShapeRotate(db, stpointLM.C2D(0,-extSide.L()), ref extSide, pierH, topW, slopeW, topW, slopeW, brslope, dr, out hs, out ws, "H钢筋", scale);

            TextPloter.AddTitleRotate(db, stpointLM.C2D(-8 * scale, 0), ref extSide, "A-A", "", scale);
            string text = @"注
 1.本图尺寸均以毫米为单位。";
            string steel_tower_type = dr["steel_tower_type"].ToString();

            Point3d p = stpointLM.C2D(0, -h).C3D(ws+40*scale, -(hs)+0*scale);
            TextPloter.AddMText(db, p, ref extSide, text, scale, 2.5, 55 * scale, Extensions.curFont,GeTools.DegreeToRadian(90));
            ext = ext.Add(extSide);
        }
        #endregion

        #endregion

        #region  X撑型(暂时不开发，后期有需求再处理)
        #endregion
    }
}
